//表单插件类
define(['WebPDF'], function(WebPDF) {
    'use strict';
    var FormPlugin = angular.module('FormPlugin', []);

    FormPlugin.run(['$compile', 'ToolHandlerManager', 'FormToolHandler', function($compile, ToolHandlerManager, FormToolHandler) {        

        function _createFormPage(pageView, pdfPage, docView) {       
            var newScope = pageView.scope().$new();
            newScope.pageIndex = pdfPage.pageIndex;                      
            var compiledContents = $compile('<div form-page/>');
            compiledContents(newScope, function(clone) {
                pageView.children('img').after(clone);
            });   
        }
     
        WebPDF.DocumentLoadFinished(function() {
        });

        WebPDF.PageShowCompleted(function(event, data) {           
            _createFormPage(data.pageView, data.pdfPage);
        });

        ToolHandlerManager.addIgnoreMouseEventElement('.fwr-form-fields-container>div');
        ToolHandlerManager.registerToolHandler(FormToolHandler);
       
    }]);    

    return FormPlugin;       
});